﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MarchEstate.Manager.BusinesEntity;
using MarchEstate.Manager.Dao.Carport;

namespace MarchEstate.Manager.ObjectModel.Carport
{
    public class CarArea : AbstractCarArea
    {
        public CarDao carDao = null;

        public CarArea()
        {
        }

        public override void InitDao()
        {
            base.InitDao();
            carDao = NewDao<CarDao>();
        }

        public override bool Save(string type)
        {
            if (type == "add")
            {
                if (carDao.ExistAreaModel(Code))
                {
                    throw new Exception("输入的代码已存在，请重新输入！");
                }
                return carDao.AddArea(this);
            }
            else if (type == "alter")
            {
                return carDao.UpdateArea(this);
            }
            return true;
        }

        public override bool Delete(string _code)
        {
            return carDao.DeleteCarArea(_code);
        }

        public override System.Data.DataTable GetCarAreaList()
        {
            return carDao.GetCarAreaList();
        }


    }
}
